<?php
namespace Home\Controller;

class PublicController extends \Think\Controller{
    
    //发送手机验证码
    public function sendPhoneMsg(){
		$mobile = I('post.mobile');
        if(empty($mobile)){
            die('手机号码不能为空');
        }

        //$mobile_code = '1234';
        $mobile_code = code_random(4,1);
        
        $gets = send_reg_msg($mobile,$mobile_code);
        
        if($gets){
            session('phone',$mobile);
            session('mobile_code',$mobile_code);//手机验证码
            die('suc');
        }else{
            die('短信发送失败');
        }
	}
    
    //获取城市下属医院
    public function getHpt(){
        if($res = M('Hospital')->where(array('cid'=>I('post.cid')))->select()){
            echo json_encode($res);die;
        }else{
            echo json_encode('err');die;
        }
    }
    
    public function test(){
        send_add_msg(18862175792);
    }
    
}